<?php

namespace App\Models\Entity\Asset\Vlive;

use Eloquent as Model;
use Illuminate\Database\Eloquent\SoftDeletes;

/**
 * Class Vcposter
 * @package App\Models\Entity\Asset\Vlive
 * @version December 11, 2017, 10:26 am CST
 *
 * @property \App\Models\Entity\Asset\Vlive\Vchan vchan
 * @property string vcposter_no
 * @property string name
 * @property string title
 * @property string subtitle
 * @property string short_desc
 * @property string long_desc
 * @property string cposter_url
 * @property string specification
 * @property string dimension
 * @property timestamp created_at
 * @property timestamp updated_at
 */
class Vcposter extends Model
{
    use SoftDeletes;


    public $table = 'vcposters';
    

    protected $dates = ['deleted_at'];


    public $fillable = [
        'vcposter_no',
        'name',
        'title',
        'subtitle',
        'short_desc',
        'long_desc',
        'cposter_url',
        'specification',
        'dimension',
        'listorder',
        'created_at',
        'updated_at'
    ];

    /**
     * The attributes that should be casted to native types.
     *
     * @var array
     */
    protected $casts = [
        'vcposter_no' => 'string',
        'name' => 'string',
        'title' => 'string',
        'subtitle' => 'string',
        'short_desc' => 'string',
        'long_desc' => 'string',
        'cposter_url' => 'string',
        'specification' => 'integer',
        'dimension' => 'string',
        'listorder' => 'integer'
    ];

    /**
     * Validation rules
     *
     * @var array
     */
    public static $rules = [
        'vcposter_no' => 'required|max:100|unique:vcposter,vcposter_no',
        'name' => 'required',
        'cposter_url' => 'required'
    ];

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     **/
    public function vchan()
    {
        return $this->belongsTo(\App\Models\Entity\Asset\Vlive\Vchan::class, 'id');
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     * 图片规格
     **/
        public function imgtpl()
    {
        return $this->hasOne(\App\Models\Common\CatData\Image\Imgtpl::class, 'id', 'specification');
    }
}
